package PTA.javabianchengjichu2;

import java.util.Scanner;

public class ex36 {
    public static void main(String[] args) {
        Scanner sc=  new Scanner(System.in);
        int n = sc.nextInt();
        int arr[]= new int[n];

int max = 0;
int index=0;
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            arr[i]=a;
        }
        for(int i=0;i<n;i++){
            int count=0;
            for(int j=0;j<n;j++){
                if(arr[i]==arr[j]){
        count++;

                }
            }
            if(count>max){
                max=count;
                index=i;
            }
        }

        System.out.println(arr[index]+" "+max);
    }
}
